<sqx-title message="i18n:common.clients" />
<sqx-layout innerWidth="50" layout="main" titleIcon="clients" titleText="i18n:common.clients">
    <ng-container menu>
        <button class="btn btn-text-secondary" (click)="reload()" shortcut="CTRL + B" title="i18n:clients.refreshTooltip" type="button">
            <i class="icon-reset"></i> {{ "common.refresh" | sqxTranslate }}
        </button>
    </ng-container>
    <ng-container>
        <sqx-list-view innerWidth="50rem" [isLoading]="clientsState.isLoading | async">
            @if ((clientsState.isLoaded | async) && (clientsState.clients | async); as clients) {
                @if (clientsState.canCreate | async) {
                    <sqx-client-add-form />
                }

                @if (rolesState.roles | async; as roles) {
                    @for (client of clients; track client.id) {
                        <sqx-client [client]="client" [clientRoles]="roles" />
                    } @empty {
                        <div class="table-items-row table-items-row-summary table-items-row-empty">
                            {{ "clients.empty" | sqxTranslate }}
                        </div>
                    }
                }
            }
        </sqx-list-view>
    </ng-container>
    <ng-template sidebarMenu>
        <div class="panel-nav">
            <a
                class="panel-link"
                attr.aria-label="{{ 'common.history' | sqxTranslate }}"
                queryParamsHandling="preserve"
                replaceUrl="true"
                routerLink="history"
                routerLinkActive="active"
                sqxTourStep="history"
                title="i18n:common.history"
                titlePosition="left">
                <i class="icon-time"></i>
            </a>
            <a
                class="panel-link"
                attr.aria-label="{{ 'common.help' | sqxTranslate }}"
                queryParamsHandling="preserve"
                replaceUrl="true"
                routerLink="help"
                routerLinkActive="active"
                sqxTourStep="help"
                title="i18n:common.help"
                titlePosition="left">
                <i class="icon-help2"></i>
            </a>
        </div>
    </ng-template>
</sqx-layout>
<router-outlet></router-outlet>
